﻿using browser4gp.core.Helpers;
using browser4gp.Properties;
using browser4gp.ViewModels;
using browser4gp.Views;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using wpf4gp;

namespace browser4gp
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            string path = Settings.Default.mainUrl;
            if (string.IsNullOrEmpty(path))
            {
                path = "file://" + Path.Combine(EnvironmentHelper.ApplicationDirectory, "Web", "test.html");
            }
            using (BrowserViewModel model = new BrowserViewModel(path))
            {
                BrowserView view = new BrowserView(model);
                view.ShowDialog();
            }
        }

        private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Exception.ShowMessageBox();
        }
    }
}
